/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.portalcenter.model.entity;

import cn.hallele.mc.sdk.portalcenter.common.enums.DataScopeEnum;
import cn.hallele.mc.sdk.portalcenter.common.enums.RoleStatusEnum;
import jakarta.persistence.*;
import lombok.*;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * RoleEntity
 *
 * @author anle5
 * @since 2024/5/29 23:03
 */
@Getter
@Setter
@Entity
@Builder
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "pc_role")
public class RoleEntity implements Serializable {
    @Serial
    private static final long serialVersionUID = 1669089557110832848L;

    /**
     * 身份唯一标识
     * 生成策略: 从表key_generator中读取
     * name: TableGenerator唯一标识
     * pkColumnName：生成策略所对应键值的名称
     * pkColumnValue：键当前所生成的值，它的值将会随着每次创建累加
     * initialValue: 初始值
     * allocationSize: 递增至
     */
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "PcRoleEntity")
    @TableGenerator(name = "PcRoleEntity",
            table = "key_generator",
            pkColumnName = "gen_name",
            valueColumnName = "gen_value",
            pkColumnValue = "pc_role",
            initialValue = 1,
            allocationSize = 1
    )
    @Column(name = "id")
    private Integer id;

    /**
     * 角色名
     */
    @Column(name = "name")
    private String name;

    /**
     * 角色code
     */
    @Column(name = "code")
    private String code;

    /**
     * 排序
     */
    @Column(name = "sort")
    private Integer sort;

    /**
     * 状态
     */
    @Column(name = "status")
    private RoleStatusEnum status;

    /**
     * 数据权限(0-所有数据；1-租户及子部门数据；2-本租户数据；3-本人数据
     */
    @Column(name = "data_scope")
    private DataScopeEnum dataScope;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time")
    private LocalDateTime updateTime;
}
